/*package com.shankungfu.main;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONException;
import org.json.JSONObject;

import android.app.Dialog;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Matrix;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSONArray;
import com.cyou.MainApplication;
import com.cyou.expo.PhotographData;
import com.cyou.expo.PresentData;
import com.cyou.expo.R;
import com.cyou.expo.TagsData;
import com.cyou.expo.adapter.PhotographAdapter;
import com.cyou.expo.adapter.PhotographAdapter.PhotographCallBack;
import com.cyou.expo.net.WebServices;
import com.cyou.expo.utils.BroadcastReceiverHelper;
import com.cyou.expo.utils.SortList;
import com.cyou.expo.utils.TestUtils;
import com.cyou.expo.utils.ToastUtil;
import com.cyou.expo.utils.Utils;
import com.cyou.expo.view.DeletePictureDialog;
import com.cyou.expo.view.DeletePictureDialog.DeletePictureCallBack;
import com.cyou.expo.view.HorizontalListView;
import com.cyou.expo.view.PrizeDialog;
import com.cyou.expo.view.SelectPictureDialog;
import com.cyou.expo.view.SelectPictureDialog.PictureCallBack;
import com.loopj.android.http.JsonHttpResponseHandler;
import com.loopj.android.http.LibGlobleConstant;
import com.loopj.android.http.RequestParams;
import com.weibo.sdk.android.util.BitmapHelper;
import com.weibo.sdk.android.util.Utility;

*//**
 * 随手拍页面
 * 
 * @author wangqing 2013-6-24
 *//*
public class PhotographActivity extends BaseActivity implements
		OnClickListener, PhotographCallBack, PictureCallBack,
		DeletePictureCallBack {
	public static final String UPLOAD_FILE_STATUS_ACTION = "com.cyou.upload.file.status";
	public static final String STATUS_MSG = "status_msg";
	public static String photoDir = Environment.getExternalStorageDirectory() + "/ChinaJoyPicture/";
	public static String fileDir = photoDir + "MyPhotograph/";

	*//** 从我的随手拍界面返回数据点的标识 *//*
	public static final String PHOTOGARPH_POSITON = "com_cy_myPhotograph_position";
	*//** preferences文件的名字 *//*
	public static final String PREFERENCES_NAME = "com_cy_myPhotograph";
	*//** 对象存储的键 *//*
	public static final String PREFERENCES_PHOTOGRAPH_INFO_NAME = "photographInfo";
	public static final String action = "wq.gdky005.message";

	protected final int CAMERA_RESULT = 0x11;
	protected final int PHOTO_ALBUM_RESULT = 0x22;
	*//** 限制文字的总字数 *//*
	private int wordsCount = 140;

	private int selectTagId = -1;
	private String selectTagName = "";

	private MainApplication app;

	private String photoPath;
	private File dirPath;
	private File imagePath;

	private TextView title_center_text;
	private LinearLayout categoryLinearLayout;
	private RelativeLayout rl;
	private HorizontalListView photoListView;
	private PhotographAdapter photographAdapter;
	private EditText editText;

	private List<Map<String, Object>> pictureTags;
	private List<String> saveImageUrlList;
	private List<TagsData> list = null;
	private List<Object> dataList = null;
	private List<Map<String, Object>> previewList = null;
	private PhotographData photographBean = new PhotographData();

	private SharedPreferences pref;

	BroadcastReceiverHelper broadcastReceiverHelper;
	private TextView tv_text_limit;
	private Button sendMessage;
	private Dialog sendDialog;

	*//** 从我的随手拍里面进来的时候，点击发送失败的图组，重新发送。 *//*
	private int position;

	@Override
	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		setContentView(R.layout.photograph_layout);
		position = getIntent().getIntExtra(PHOTOGARPH_POSITON, -1);

		initData();
		getTags();
		setCategoryLinearLayout();
		setPositionOfSaveData(position);
	}

	@SuppressWarnings("unchecked")
	private void initData() {
		pref = getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND);
		app = (MainApplication) getApplicationContext();

		list = new ArrayList<TagsData>();
		pictureTags = new ArrayList<Map<String, Object>>();
		previewList = new ArrayList<Map<String, Object>>();
		dataList = new ArrayList<Object>();
		dataList = (List<Object>) Utils.getObjectValue(pref,
				PREFERENCES_PHOTOGRAPH_INFO_NAME, null);

		categoryLinearLayout = (LinearLayout) findViewById(R.id.picture_category);
		title_center_text = (TextView) findViewById(R.id.title_center_text);
		photoListView = (HorizontalListView) findViewById(R.id.photo_listview);
		tv_text_limit = (TextView) findViewById(R.id.tv_text_limit);
		sendMessage = (Button) findViewById(R.id.sendMessage);
		editText = (EditText) findViewById(R.id.fresh_news);
		title_center_text.setText(R.string.my_photograph_titlt);

		photographAdapter = new PhotographAdapter(this, previewList, this);
		photoListView.setAdapter(photographAdapter);
		editText.addTextChangedListener(new TextWatcher() {

			@Override
			public void onTextChanged(CharSequence s, int start, int before,
					int count) {
				// 这些是对文本进行监听，如果有变化就对把文本上的数字改动，让用户知道输入多少数字了，如果过多或者没有输入就把发送按钮变成不可点击的形式！
				String textContent = editText.getText().toString();
				int len = textContent.trim().length();
				if (len <= wordsCount) {

					tv_text_limit.setTextColor(Color.GRAY);
					tv_text_limit.setText(len + "/" + wordsCount + getString(R.string.text_zi));
				} else {

					tv_text_limit.setTextColor(Color.RED);
					tv_text_limit.setText(len + "/" + wordsCount + getString(R.string.text_zi));
				}
			}

			@Override
			public void beforeTextChanged(CharSequence s, int start, int count,
					int after) {
			}

			@Override
			public void afterTextChanged(Editable s) {
			}
		});
	}

	*//**
	 * 从我的随手拍进来后，重发的数据。 wangqing 2013-7-3 void
	 * 
	 * @param position
	 *//*
	private void setPositionOfSaveData(int position) {
		if (dataList != null && position != -1) {

			if (dataList != null && dataList.size() > 0) {
				PhotographData bean = (PhotographData) dataList.get(position);
				editText.setText(bean.getContent());
				List<String> listStr = new ArrayList<String>();
				listStr = bean.getImageUrls();
				if (listStr != null && listStr.size() > 0) {
					for (int i = 0; i < listStr.size(); i++) {
						previewList.add(flushPhotograpAdatapterData(listStr
								.get(i)));
					}
				}
				photographAdapter.setList(previewList);
				photographAdapter.notifyDataSetChanged();

			}
		}
	}

	*//**
	 * 获取 网络的标签 wangqing 2013-7-3 void
	 *//*
	private void getTags() {
		WebServices webServices = new WebServices();

		RequestParams params = WebServices.communalParams();
		params.put("exhibitId", app.getOnGoingExhibitId() + "");
		// 默认启动标签，不启用传 0
		params.put("status", "1");

		JsonHttpResponseHandler responseHandler = new JsonHttpResponseHandler() {
			@Override
			protected void handleFailureMessage(Throwable e,
					String errorResponse) {

				super.handleFailureMessage(e, errorResponse);
				ToastUtil.showMessageText(PhotographActivity.this, getString(R.string.getTags_failure));
				TestUtils.logI("错误内容：" + e + ", json响应错误： " + errorResponse);
			}

			@Override
			public void onSuccess(int stateCode, JSONObject response) {

				super.onSuccess(stateCode, response);
				TestUtils.logI("服务器的状态是：" + stateCode + ", 服务器返回的内容是： "
						+ response);
				JSONObject jsonObject;
				try {
					jsonObject = response.getJSONObject("result");
					if (null != jsonObject
							&& jsonObject.getJSONArray("list") instanceof org.json.JSONArray) {

						String reuslt = jsonObject.getJSONArray("list")
								.toString();
						if (!TextUtils.isEmpty(reuslt)) {

							list = JSONArray.parseArray(reuslt, TagsData.class);

							if (list.size() > 0) {
								for (int i = 0; i < list.size(); i++) {
									Map<String, Object> tempMap = new HashMap<String, Object>();
									tempMap.put("id", list.get(i).getId());
									tempMap.put("name", list.get(i).getName());
									pictureTags.add(tempMap);
								}
								setCategoryLinearLayout();
							} else {
								ToastUtil.showMessageText(
												PhotographActivity.this,
												getString(R.string.tags_isempty));
							}
						}
					}
				} catch (JSONException e) {
					e.printStackTrace();
					ToastUtil.showMessageText(
							PhotographActivity.this,
							getString(R.string.data_parse_failure));
				}
			}
		};
		TestUtils.logI(params.toString());
		webServices.requestPhotograpthTagsList(params, responseHandler);
	}

	*//**
	 * 发送随手拍到服务器，包含图片和文字。 wangqing 2013-6-26 void
	 *//*
	private void sendMessage(String content) {
		String fileName = "";
		saveImageUrlList = new ArrayList<String>();
		List<String> fileWidthList = new ArrayList<String>();
		List<String> fileHigthList = new ArrayList<String>();
		WebServices webServices = new WebServices();

		RequestParams params = WebServices.communalParams();
		params.put("exhibitId", app.getOnGoingExhibitId() + "");
		if (selectTagId >= 0) {
			params.put("tagid", selectTagId + "");
			params.put("tag", selectTagName);
		}
		params.put("name", content);
		params.put("timestamp", System.currentTimeMillis() + "");

		LibGlobleConstant.libState = true;
		LibGlobleConstant.libMultipartKey = "data";
		for (int i = 0; i < previewList.size(); i++) {
			Map<String, Object> map = previewList.get(i);
			try {
				String imagePath = (String) map.get("imagePath");
//				saveImageUrlList.add(imagePath);
				BitmapFactory.Options options = new BitmapFactory.Options();
				options.inJustDecodeBounds = false;
				options.inSampleSize = 6;// 宽度和高度设置为原来的1/6
				FileInputStream fileInputStream = new FileInputStream(imagePath);
				Bitmap bitmap = BitmapFactory.decodeStream(fileInputStream,
						null, options);
				ByteArrayOutputStream baos = new ByteArrayOutputStream();
				bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);

				byte[] b = baos.toByteArray();

				// 对图片的二次处理
				double size = b.length / 1024; // KB
				if (size > 100) { // 进行压缩
					ByteArrayOutputStream baoStream = new ByteArrayOutputStream();
					double j = size / 400;
					Bitmap bmp = zooImage(bitmap,
							bitmap.getWidth() / Math.sqrt(j),
							bitmap.getHeight() / Math.sqrt(j));
					bmp.compress(Bitmap.CompressFormat.JPEG, 100, baoStream);
					b = baos.toByteArray();
				}
				fileName = imagePath
						.substring(imagePath.lastIndexOf("/") + 1,
								imagePath.length());
				fileWidthList.add(bitmap.getWidth() + "");
				fileHigthList.add(bitmap.getHeight() + "");
				params.put("data" + i, new ByteArrayInputStream(b), fileName);
					
				writeDataToFile(b, fileDir + fileName);
				saveImageUrlList.add(fileDir + fileName);
				
			} catch (FileNotFoundException e1) {
				e1.printStackTrace();
			}
		}

		String fileWidths = fileWidthList.toString();
		String fileHigths = fileHigthList.toString();
		params.put("dataWidth",
				fileWidths.substring(1, fileWidths.length() - 1));
		params.put("dataHeight",
				fileHigths.substring(1, fileHigths.length() - 1));

		photographBean.setContent(content);
		if (saveImageUrlList != null && saveImageUrlList.size() > 0) {
			photographBean.setImageUrls(saveImageUrlList);
			photographBean.setType(2);
			photographBean.setFirstPicURL(saveImageUrlList.get(0));
		} else {
			photographBean.setType(1);
		}

		// 获取第一个图片的宽和高，存入本地
		if (fileHigthList != null && fileHigthList.size() > 0
				&& fileWidthList != null && fileWidthList.size() > 0) {
			photographBean.setFirstPicHeight(fileHigthList.get(0));
			photographBean.setFirstPicWidth(fileWidthList.get(0));
		}

		photographBean.setCurrentTime(System.currentTimeMillis() + "");
		JsonHttpResponseHandler responseHandler = new JsonHttpResponseHandler() {
			@Override
			protected void handleFailureMessage(Throwable e,
					String errorResponse) {

				super.handleFailureMessage(e, errorResponse);
				sendDialog.dismiss();
				photographBean.setSendState(false);
				photographBean.setSendStateMsg(getString(R.string.send_failure));
				sendMessage.setFocusable(true);
				savePhotographInfo();
				ToastUtil.showMessageText(PhotographActivity.this,
						getString(R.string.retry));
				// 发送失败的广播！
				Intent i = new Intent(UPLOAD_FILE_STATUS_ACTION);
				i.putExtra(STATUS_MSG, getString(R.string.send_failure));
				sendBroadcast(i);
				TestUtils.logI("错误内容：" + e + ", json响应错误： " + errorResponse);
			}

			@Override
			public void onSuccess(int stateCode, JSONObject response) {

				super.onSuccess(stateCode, response);
				TestUtils.logI("服务器的状态是：" + stateCode + ", 服务器返回的内容是： "
						+ response);
				try {
					int status = response.getInt("status");
					if (status == 0) {
						String result = response.getJSONObject("result")
								.toString();
						TestUtils.logI("发布随手拍后获取的数据是：" + result);
						PresentData presentBean = com.alibaba.fastjson.JSONObject
								.parseObject(result, PresentData.class);
						// 提示用户中奖了
						if (!TextUtils.isEmpty(presentBean.getPic())
								&& !TextUtils.isEmpty(presentBean.getUuid())) {
							PrizeDialog dialog = new PrizeDialog(
									PhotographActivity.this,
									R.style.Transparent);
							dialog.setCancelable(true);
							dialog.show();
							dialog.setImageView(presentBean.getPic(),
									presentBean.getUuid());
							photographBean.setPic(presentBean.getPic());
							photographBean.setUuid(presentBean.getUuid());
						}
						photographBean.setPicsId(presentBean.getPicsId());
						photographBean.setPicsUuid(presentBean.getPicsUuid());
						photographBean.setSendState(true);
						photographBean.setSendStateMsg(getString(R.string.send_success));
						savePhotographInfo();
						ToastUtil.showMessageText(PhotographActivity.this,
								getString(R.string.my_photograph_success));
						// 发送成功的广播！
						Intent i = new Intent(UPLOAD_FILE_STATUS_ACTION);
						i.putExtra(STATUS_MSG, getString(R.string.send_success));
						sendBroadcast(i);
						// 用户未获奖
						TestUtils.logI(presentBean.getPic());
					} else {
						photographBean.setSendState(false);
						photographBean.setSendStateMsg(getString(R.string.send_failure));
						savePhotographInfo();
						// 发送失败的广播！
						ToastUtil.showMessageText(PhotographActivity.this,
								getString(R.string.retry));
						Intent i = new Intent(UPLOAD_FILE_STATUS_ACTION);
						i.putExtra(STATUS_MSG, getString(R.string.send_failure));
						sendBroadcast(i);
					}
				} catch (JSONException e) {
					e.printStackTrace();

					// TODO
					// 发送失败的广播！
					photographBean.setSendState(false);
					photographBean.setSendStateMsg(getString(R.string.send_failure));
					savePhotographInfo();
					Intent i = new Intent(UPLOAD_FILE_STATUS_ACTION);
					i.putExtra(STATUS_MSG, getString(R.string.send_failure));
					sendBroadcast(i);
				}

				sendDialog.dismiss();
				sendMessage.setFocusable(true);
			}

			*//**
			 * 发送成功后，清除已有的东西 wangqing 2013-7-3 void
			 *//*
			private void clearData() {
				editText.setText("");
				previewList.clear();
				photographAdapter.setList(previewList);
				photographAdapter.notifyDataSetChanged();
				changeButton();
			}

			*//**
			 * 保存 照片图集的Info信息 wangqing 2013-7-2 void
			 *//*
			private void savePhotographInfo() {
				if (photographBean != null) {
					if (dataList == null) {
						dataList = new ArrayList<Object>();
					}
					dataList.add(photographBean);
					photographBean = new PhotographData();
					clearTempData();
				}
				clearData();

				SortList<Object> sortList = new SortList<Object>();
				sortList.Sort(dataList, "getCurrentTime", "desc");
				// 存储图片和文本以及相关信息到文件里面
				boolean state = Utils.saveObjectValue(pref,
						PREFERENCES_PHOTOGRAPH_INFO_NAME, dataList);

				// TestUtils.logI("dataList里面的数据是：" + dataList.toString());

				// 测试文件是否成功
				// if (state) {
				// dataList = (List<Object>) Utils.getObjectValue(pref,
				// PREFERENCES_PHOTOGRAPH_INFO_NAME, photographBean);
				// PhotographBean bean = (PhotographBean) dataList.get(1);
				// TestUtils.logI(bean.getContent());
				// }
			}
		};
		TestUtils.logI("发送随手拍的数据是： " + params.toString());
		webServices.sendPhotographMessage(params, responseHandler);
	}

	*//**
	 * 将处理过的图片保存到本地的 /ChinaJoyPicture/MyPhotograph/ 目录下面
	 * wangqing
	 * 2013-7-12
	 * void
	 * @param b
	 * @param fileName
	 *//*
	private void writeDataToFile(byte[] b, String fileName) {
		try {
			File dir  = new File(fileDir);
			if (!dir.exists()) {
				dir.mkdirs();
			}
			FileOutputStream fos = new FileOutputStream(fileName);
			fos.write(b);
		} catch (IOException e1) {
			e1.printStackTrace();
		}
	}

	*//**
	 * 压缩图片 WangQing 2013-6-27
	 *//*
	private Bitmap zooImage(Bitmap bitmap, double newWidth, double newHeight) {

		// 获取这个图片的宽和高
		float width = bitmap.getWidth();
		float height = bitmap.getHeight();
		// 创建图片用的matrix对象
		Matrix matrix = new Matrix();
		// 计算宽高缩放率
		float scaleWidth = ((float) newWidth) / width;
		float scaleHeight = ((float) newHeight) / height;
		// 缩放图片动作
		matrix.postScale(scaleWidth, scaleHeight);
		Bitmap bmp = Bitmap.createBitmap(bitmap, 0, 0, (int) width,
				(int) height, matrix, true);
		return bmp;
	}

	*//**
	 * 动态创建种类标签 wangqing 2013-6-9 void
	 *//*
	private void setCategoryLinearLayout() {
		*//** 设置Button的margin值 *//*
		int spaceBetween = 10;
		// 第三个参数设置权重
		LayoutParams includeViewParams = new LayoutParams(
				LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
		includeViewParams.setMargins(spaceBetween, spaceBetween, spaceBetween,
				spaceBetween);
		includeViewParams.width = Integer
				.valueOf((MainApplication.screenWidth - Utils.DipToPixels(this,
						spaceBetween) * 2 * 3) / 3);

		LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,
				LayoutParams.WRAP_CONTENT);

		int tagLength = pictureTags.size();
		for (int i = 0; i < tagLength; i += 3) {
			// 创建一个LinearLayout
			LinearLayout linearLayout_include = new LinearLayout(this);
			categoryLinearLayout.addView(linearLayout_include, layoutParams);

			for (int j = i; j < i + 3 && j < tagLength; j++) {
				Map<String, Object> tag = pictureTags.get(i + j % 3);
				TestUtils.logI("AAA你的标签数据是" + i + j % 3);
				// 创建Button
				final Button button = new Button(this);
				button.setText(String.valueOf(tag.get("name")));
				button.setTag(tag.get("id"));
				button.setBackgroundResource(R.drawable.photopgraph_tag);
				button.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View v) {
						changeButton();
						selectTagName = ((Button) v).getText().toString();
						selectTagId = (Integer) ((Button) v).getTag();
						button.setBackgroundResource(R.drawable.photopgraph_tag_press);

					}

				});
				linearLayout_include.addView(button, includeViewParams);

			}
		}

	}

	*//**
	 * 改变图片的状态为默认状态 wangqing 2013-7-3 void
	 *//*
	private void changeButton() {
		int count = categoryLinearLayout.getChildCount();
		for (int k = 0; k < count; k++) {
			LinearLayout view = (LinearLayout) categoryLinearLayout
					.getChildAt(k);

			for (int l = 0; l < view.getChildCount(); l++) {
				Button button = (Button) view.getChildAt(l);
				button.setBackgroundResource(R.drawable.photopgraph_tag);
			}
		}
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {

		super.onActivityResult(requestCode, resultCode, data);

		if (requestCode == CAMERA_RESULT && resultCode == RESULT_OK) {

			TestUtils.logI("选择的图片的地址是： " + photoPath);
			previewList.add(flushPhotograpAdatapterData(photoPath));

			photographAdapter.setList(previewList);
			photographAdapter.notifyDataSetChanged();
		} else if (requestCode == PHOTO_ALBUM_RESULT && resultCode == RESULT_OK) {
			Bitmap bm = null;
			// 外界的程序访问ContentProvider所提供数据 可以通过ContentResolver接口
			ContentResolver resolver = getContentResolver();
			Uri uri = data.getData();
			// 获得路径
			String[] proj = { MediaStore.Images.Media.DATA };
			Cursor cursor = managedQuery(uri, proj, null, null, null);
			int column_index = cursor
					.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
			cursor.moveToFirst();
			// 最后根据索引值获取图片路径
			String path = cursor.getString(column_index);

			TestUtils.logI("选择的图片的地址是： " + path);
			previewList.add(flushPhotograpAdatapterData(path));

			photographAdapter.setList(previewList);
			photographAdapter.notifyDataSetChanged();
		}
	}

	private Map<String, Object> flushPhotograpAdatapterData(String path) {
		
		Bitmap bitmap = getSafeBitmap(path);
//		TestUtils.logI("转换后的BitmapWidthAndHight：" + bitmap.getWidth()+"*"+bitmap.getHeight());
		// map中存储的应该是图片的标识和地址
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("imagePath", path);
		if (bitmap != null) {
			map.put("imageBitmap", createBitmap(bitmap));
		}
		return map;
	}

	*//**
	 * 获取安全的Bitmap对象，并且是最合适的
	 * wangqing
	 * 2013-7-12
	 * Bitmap
	 * @param path
	 * @return
	 *//*
	private Bitmap getSafeBitmap(String path) {
		if (BitmapHelper.verifyBitmap(path)) {
			BitmapFactory.Options options = new BitmapFactory.Options();
			options.inJustDecodeBounds = false;
			options.inSampleSize = 1;
			try{
				Bitmap bmp = BitmapFactory.decodeFile(path, options);
				
				int sampleSize = BitmapHelper.getSampleSizeAutoFitToScreen(MainApplication.screenWidth, MainApplication.screenHight,
						bmp.getWidth(), bmp.getHeight());
				if (bmp.isRecycled()) {
					bmp.recycle();
				}
				TestUtils.logI("screenWidthAndHight：" + MainApplication.screenWidth+"*"+MainApplication.screenHight+"BitmapWidthAndHight：" + bmp.getWidth()+"*"+bmp.getHeight());
				options.inJustDecodeBounds = false;
				options.inSampleSize = sampleSize;
				TestUtils.logI("sampleSize：" + sampleSize);
				return Utility.UploadImageUtils.safeDecodeBimtapFile(path, options);
			}catch(OutOfMemoryError e){
				e.printStackTrace();
			}catch (Exception e) {
				e.printStackTrace();
			}
			
		}
		return null;
	}

	*//**
	 * 转换BitMap 的宽和高 wangqing 2013-7-2 Bitmap
	 * 
	 * @param bitmapHeight
	 * @param bitmapWidth
	 * @param bitmap
	 * @return
	 *//*
	private Bitmap createBitmap(Bitmap bitmap) {
		if (bitmap != null) {
			int pix = Utils.DipToPixels(this, 100);
			int bitmapWidth = bitmap.getWidth() <= pix ? bitmap.getWidth()
					: pix;
			int bitmapHeight = bitmap.getHeight() <= pix ? bitmap.getHeight()
					: pix;
			return Bitmap.createScaledBitmap(bitmap, bitmapWidth, bitmapHeight, false);
		}

		return bitmap;

	}

	@Override
	protected void onStart() {

		broadcastReceiverHelper = new BroadcastReceiverHelper(this, rl);
		broadcastReceiverHelper.registerAction(action);
		super.onStart();
	}

	@Override
	protected void onStop() {
		unregisterReceiver(broadcastReceiverHelper);
		super.onStop();
	}

	@Override
	protected void onDestroy() {

		super.onDestroy();
		clearTempData();
	}

	*//**
	 * 清除数据
	 * wangqing
	 * 2013-7-12
	 * void
	 *//*
	private void clearTempData() {
		selectTagId = -1;
		for (int i = 0; i < previewList.size(); i++) {
			previewList.get(i).clear();
		}
		previewList.clear();
		System.gc();
	}

	@Override
	public void onClick(View v) {

		switch (v.getId()) {
		case R.id.goback:
			this.finish();
			break;
		case R.id.sendMessage: // 发送消息
			sendMessage.setFocusable(false);
			String textContent = editText.getText().toString().trim();
			int len = textContent.length();
			if (len > wordsCount) {
				ToastUtil.showMessageText(PhotographActivity.this,
						getString(R.string.input_data_too_long) + wordsCount + getString(R.string.text_end));
				sendMessage.setFocusable(true);
			} else if (len == 0 && previewList.size() == 0) {
				ToastUtil.showMessageText(this, getString(R.string.do_you_say));
			} else {

				if (len == 0 && previewList.size() > 0) {
					textContent = getString(R.string.this_cj);
				}

				if (position != -1) {
					dataList.remove(position);
				}
				sendDialog = new Dialog(this);
				sendDialog.setTitle(R.string.sending);
				sendDialog.setCancelable(true);
				sendDialog.show();
				sendMessage(textContent);
			}

			break;
		default:
			break;
		}
	}

	*//**
	 * 调用系统的照相机 wangqing 2013-6-13 void
	 *//*
	private void pictureForCamera() {
		Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
		
		try {
			photoPath = photoDir+ getPhotoFileName();
			dirPath = new File(photoDir);
			imagePath = new File(photoPath);
			if (!dirPath.exists()) {
				dirPath.mkdir();
			}
			if (!imagePath.exists()) {
				imagePath.createNewFile();
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(imagePath));
		startActivityForResult(intent, CAMERA_RESULT);
	}

	*//**
	 * 从相册选择照片 wangqing 2013-6-13 void
	 *//*
	private void pictureForAlbum() {
		Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
		intent.setType("image/*");
		// intent.putExtra("crop", "true");
		// //从相册选择图片，并对图片剪辑,下面是对图片的剪切处理
		intent.putExtra("aspectX", 1);
		intent.putExtra("aspectY", 1);
		intent.putExtra("outputX", 200);
		intent.putExtra("outputY", 200);
		intent.putExtra("return-data", true);

		startActivityForResult(intent, PHOTO_ALBUM_RESULT);
	}

	*//** 获取照片的名字 *//*
	private String getPhotoFileName() {
		Date date = new Date(System.currentTimeMillis());
		SimpleDateFormat dateFormat = new SimpleDateFormat(
				"'IMG'_yyyyMMdd_HHmmss");
		return dateFormat.format(date) + ".jpg";
	}

	@Override
	public void selectAPhoto() {

		SelectPictureDialog dialog = new SelectPictureDialog(this,
				R.style.Transparent, this);
		dialog.show();
	}

	*//** 删除图片 *//*
	@Override
	public void deletekAPhoto(Map<String, Object> map) {

		DeletePictureDialog dialog = new DeletePictureDialog(this,
				R.style.Transparent, this);
		dialog.show();
		dialog.setMap(map);
	}

	@Override
	public void photograph() {
		pictureForCamera();
	}

	@Override
	public void selectPicture() {
		pictureForAlbum();
	}

	@Override
	public void deletePicture(Map<String, Object> map) {
		previewList.remove(map);
		photographAdapter.setList(previewList);
		photographAdapter.notifyDataSetChanged();
	}

}
*/